package IteratorAndComposite.composite.compositeIterator;

import java.util.Iterator;
import java.util.Stack;

/**
 * 实现了迭代器接口
 * @Author: pengzx
 * @Description:
 * @Date: 16:28 2017/9/26
 * @Modified by: 1.0
 */
public class CompositeIterator implements Iterator {
    Stack stack = new Stack();

    //把将要迭代的迭代器放到一个堆栈中
    public CompositeIterator(Iterator iterator)
    {
        stack.push(iterator);
    }

    @Override
    public boolean hasNext()
    {
        return false;
    }

    @Override
    public Object next()
    {
        if (stack.empty()){
            /**
             * 查看堆栈内是否被清空，如果被清空了就说明没有下一个元素了
             */
            return false;
        }else{
            Iterator iterator = (Iterator) stack.peek();
        }
        return null;
    }
}
